<!--留言反馈·已读-->

#include('head.html')
	</head>
	<script>
	#if(page>feedbacks.totalPages)
		window.location.href="/backstage/feedback2?key=${search}&page=${feedbacks.totalPages}";
	#end
	</script>
	<body>
		<div class="admin-content-body">


			<hr>
			<header class="am-topbar" style="background:none;">
				<h1 class="am-text-primary am-topbar-brand">
					<p style="font-size: 1.8rem;color: #0e90d2;font-weight: 700;">留言反馈</p>
				</h1>

				<button type="button" class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#doc-topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

				<div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse">
					<ul class="am-nav am-nav-pills am-topbar-nav">
						<li><a href="feedback">未读</a></li>
						<li class="am-active"><a>已读</a></li>
					</ul>
				</div>
			</header>


			<div class="am-g">
				<div class="am-u-sm-12 am-u-md-6">
					<div class="am-btn-toolbar">
						<div class="am-btn-group am-btn-group-xs">
							#if(search=="")
							<button type="button" class="am-btn am-btn-default addon"><span class="am-icon-refresh"></span> 刷新</button>
							#else
							<button type="button" class="am-btn am-btn-default" onclick="location.href='/backstage/feedback2'">
								<span class="am-icon-chevron-left"></span> 返回
							</button>
							#end
							<!--<button type="button" style="display:none;" class="am-btn am-btn-default am-text-success morecheck readMore"><span class="am-icon-pencil-square-o"></span> 标已读</button>-->
							<button type="button" style="display:none;" class="am-btn am-btn-default am-text-secondary morecheck unreadMore"><span class="am-icon-pencil-square-o"></span> 标未读</button>
							<button type="button" style="display:none;" class="am-btn am-btn-default am-text-danger morecheck deleteMore">
								<span class="am-icon-trash-o"></span> 删除
							</button>
						</div>
					</div>
				</div>
				<div class="am-u-sm-12 am-u-md-3">

				</div>
				<div class="am-u-sm-12 am-u-md-3">
					<div class="am-input-group am-input-group-sm">
						<input type="text" style="color:red;" placeholder="请输入查询关键字" id="con" class="am-form-field" value="${search}">
						<span class="am-input-group-btn">
            <button type="button" class="am-btn am-btn-default search" type="button">搜索</button>
          </span>
					</div>
				</div>
			</div>
			<div class="am-g">
				<div class="am-u-sm-12">
					<form method="post" action="/backstage/feedback_unread">
						<input type="hidden" name="ids" id="ids">
						<table class="am-table am-table-striped am-table-hover table-main">
							<thead>
								<tr>
									<th class="table-check"><input class="chooseall" type="checkbox"></th>
									<th class="table-id">ID</th>
									<th class="table-title">内容摘要</th>
									<th class="table-author am-hide-sm-only">反馈者</th>
									<th class="table-date am-hide-sm-only">提交时间</th>
									<th class="table-set">操作</th>
								</tr>
							</thead>
							<tbody>
							#set(i=0)
							#for(Feedback feedback : feedbacks.getRows())
								<tr>
									<td><input type="checkbox" name="checkbox" value="${feedback.f_id}"></td>
									<td>${feedback.f_id}</td>
									<td>
										<a onclick="lookThis(${feedback.f_id})">
											#if(feedback.f_content.length()>10)
											$!{feedback.f_content.substring(0,10)}...
											#else
											$!{feedback.f_content}
											#end
										</a>
									</td>

									<td class="am-hide-sm-only">
										<a onclick="member(${members[i].m_id})">${members[i].m_realname}</a>
									</td>
									<td class="am-hide-sm-only">${feedback.f_time.substring(0,19)}</td>
									<td>
										<div class="am-btn-toolbar">
											<div class="am-btn-group am-btn-group-xs">
												<button type="button" onclick="lookThis(${feedback.f_id})" class="am-btn am-btn-default am-btn-xs am-text-secondary lookThis"><span class="am-icon-book"></span> 查看</button>
												<button type="button" class="am-btn am-btn-default am-btn-xs am-hide-sm-only unread"><span class="am-icon-pencil-square-o"></span> 标未读</button>
												<button type="button" style="display:none !important;" class="am-btn am-btn-default am-btn-xs am-text-success am-hide-sm-only read"><span class="am-icon-pencil-square-o"></span> 标已读</button>
												<button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only deleteThis"><span class="am-icon-trash-o"></span> 删除</button>
											</div>
										</div>
									</td>
								</tr>
							#set(i=i+1)
							#end
							#if(i==0)
							<tr><td class="am-hide-sm-only"></td><td></td><td></td><td>暂无记录！</td><td></td><td class="am-hide-sm-only"></td></tr>
							#end
							</tbody>
						</table>
						<div class="am-cf">
							共 ${feedbacks.getTotalRows()} 条记录
							#if(search!="")(查询结果）
							#end
							<div class="am-fr">
								<ul class="am-pagination">
									<li class="${feedbacks.isHasPrevPage()  ? '':'am-disabled'}">
										<a href="/backstage/feedback2?key=${search}&page=${feedbacks.getPrevPage()}">«</a>
									</li>
									#set(j=feedbacks.getPageNum()-(feedbacks.getPageNum()%5!=0?feedbacks.getPageNum()%5:5)+1)
									#for(i : range(j, (j+4) > feedbacks.totalPages ? feedbacks.totalPages : j+4))
									<li class="${i == feedbacks.pageNum  ? 'am-active':''}">
										<a href="/backstage/feedback2?key=${search}&page=${i}">${i}</a>
									</li>
									#end
									<li class="${feedbacks.isHasNextPage()  ? '':'am-disabled'}">
										<a href="/backstage/feedback2?key=${search}&page=${feedbacks.getNextPage()}">»</a>
									</li>
								</ul>
							</div>
						</div>
						<hr>
					</form>
				</div>
			</div>
		</div>
		#include('/backstage/footer.html')
		<script type="text/javascript" src="/static/js/backstage/jquery-1.8.3.js"></script>
		<script type="text/javascript" src="/static/js/backstage/amazeui.min.js"></script>
		<script type="text/javascript" src="/static/js/backstage/choose.js" ></script>
		<script type="text/javascript" src="/static/js/backstage/plugs.js" ></script>
		<script>

		function lookThis(id){
					$.jq_Panel({
						title: "反馈详情",
						iframeWidth: 500,
						iframeHeight: 300,
						url: "feedbackDetail/"+id
					});
		}

		function member(id){
					window.parent.$.jq_Panel({
						title: "成员信息",
						iframeWidth: 700,
						iframeHeight: 500,
						url: "/users/"+id
					});
			}

		function check(){
			var checkID = [];//定义一个空数组
			$("input[name='checkbox']:checked").each(function(j){//把所有被选中的复选框的值存入数组
				 checkID[j] =$(this).val();
			});
			$("#ids").val(checkID);
		}

		$(function() {

			$(".addon").click(function() {
				window.location.href=location.href;	//刷新
			});

			$(".search").click(function(){
			    window.location.href="/backstage/feedback2?key="+$("#con").val();
			});

			$(".read").click(function(){
					$("#ids").val($(this).parents("tr").find("input[name='checkbox']").val());
			        $.ajax({
                        url:"/backstage/feedback_isread/1",
                        dataType:"json",
                        type:"post",
                        data:$("form").serialize(),
                        success:function(result){
                           	alert("标为已读!");
							window.location.href=location.href;
                        },
                        error:function(result){
                            alert("系统繁忙！");
                         }
                    });
					$(this).attr("style","display:none !important");
					$(this).prev().attr("style","display:block !important");
			});
			$(".unread").click(function(){
					$("#ids").val($(this).parents("tr").find("input[name='checkbox']").val());
			        $.ajax({
							url:"/backstage/feedback_isread/0",
							dataType:"json",
							type:"post",
							data:$("form").serialize(),
							success:function(result){
								alert("标为未读！");
								window.location.href=location.href;
							},
							error:function(result){
              				  	alert("系统繁忙！");
           					 }
						});
					$(this).attr("style","display:none !important");
					$(this).next().attr("style","display:block !important");
			});
			$(".readMore").click(function() {
					if(confirm('确定批量标注已读吗？')){
						check();
        				$.ajax({
							url:"/backstage/feedback_isread/1",
							dataType:"json",
							type:"post",
							data:$("form").serialize(),
							success:function(result){
								alert(result.tips+"条记录标为已读！");
								window.location.href=location.href;
							},
							error:function(result){
              				  	alert("系统繁忙！");
           					 }
						});
						$('tbody input[type=checkbox]:checked').parents("tr").find(".read").attr("style","display:none !important");
						$('tbody input[type=checkbox]:checked').parents("tr").find(".unread").attr("style","display:block !important");
						$("thead input[type='checkbox']").prop("checked", true).click();
					}
			});
			$(".unreadMore").click(function() {
					if(confirm('确定批量标注未读吗？')){
						check();
        				$.ajax({
							url:"/backstage/feedback_isread/0",
							dataType:"json",
							type:"post",
							data:$("form").serialize(),
							success:function(result){
								alert(result.tips+"条记录标为未读！");
								window.location.href=location.href;
							},
							error:function(result){
              				  	alert("系统繁忙！");
           					 }
						});
						$('tbody input[type=checkbox]:checked').parents("tr").find(".unread").attr("style","display:none !important");
						$('tbody input[type=checkbox]:checked').parents("tr").find(".read").attr("style","display:block !important");
						$("thead input[type='checkbox']").prop("checked", true).click();
					}
			});

			$(".deleteThis").click(function() {
					if(confirm('确定删除吗？')){
						$("#ids").val($(this).parents("tr").find("input[name='checkbox']").val());
			        	$.ajax({
							url:"/backstage/feedback_delete",
							dataType:"json",
							type:"post",
							data:$("form").serialize(),
							success:function(result){
								alert("删除成功！");
								window.location.href=location.href;
							},
							error:function(result){
              				  	alert("系统繁忙！");
           					 }
						});
						<!--$(this).parents("tr").remove();-->
					}
			});
			$(".deleteMore").click(function() {
					if(confirm('确定删除吗？')){
						check();
        				$.ajax({
							url:"/backstage/feedback_delete",
							dataType:"json",
							type:"post",
							data:$("form").serialize(),
							success:function(result){
								alert(result.tips+"条记录删除成功！");
								window.location.href=location.href;
							},
							error:function(result){
              				  	alert("系统繁忙！");
           					 }
						});
						<!--$('tbody input[type=checkbox]:checked').parents("tr").remove();-->
						$("thead input[type='checkbox']").prop("checked", true).click();
					}
			});
		});
		</script>
	</body>
</html>